package com.fd.array;

import java.util.Arrays;
import java.util.Scanner;

public class ArrayDemo {
    public static void main(String[] args) {
        inputScore();
    }
    public static void inputScore() {
        double [] scores = new double[8];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个同学的分数：");
            scores[i] = sc.nextDouble();
        }
        System.out.println(Arrays.toString(scores));
        // 3, 遍历数组，预计总分，统计最高分，统计最低分，统计平均分
        double sum = 0;
        double max = scores[0];
        double min = scores[0];
        for (int i = 0; i < scores.length; i++){
            sum += scores[i];
            if (scores[i] > max) {
                max = scores[i];
            }
            if (scores[i] < min) {
                min = scores[i];
            }
        }
        System.out.println("总分：" + sum);
        System.out.println("平均分：" + sum / scores.length);
        System.out.println("最高分：" + max);
        System.out.println("最低分：" + min);
    }
}
